package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoGalleryExhibitionType;
import com.muyu.danmo.service.IDanmoGalleryExhibitionTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 展览方式Controller
 *
 * @author yangle
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/exhibitionType")
public class DanmoGalleryExhibitionTypeController extends BaseController
{
    @Autowired
    private IDanmoGalleryExhibitionTypeService danmoGalleryExhibitionTypeService;

    /**
     * 查询展览方式列表
     */
    @RequiresPermissions("system:exhibitionType:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoGalleryExhibitionType>> list(DanmoGalleryExhibitionType danmoGalleryExhibitionType)
    {
        startPage();
        List<DanmoGalleryExhibitionType> list = danmoGalleryExhibitionTypeService.selectDanmoGalleryExhibitionTypeList(danmoGalleryExhibitionType);
        return getDataTable(list);
    }

    /**
     * 导出展览方式列表
     */
    @RequiresPermissions("system:exhibitionType:export")
    @Log(title = "展览方式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoGalleryExhibitionType danmoGalleryExhibitionType)
    {
        List<DanmoGalleryExhibitionType> list = danmoGalleryExhibitionTypeService.selectDanmoGalleryExhibitionTypeList(danmoGalleryExhibitionType);
        ExcelUtil<DanmoGalleryExhibitionType> util = new ExcelUtil<DanmoGalleryExhibitionType>(DanmoGalleryExhibitionType.class);
        util.exportExcel(response, list, "展览方式数据");
    }

    /**
     * 获取展览方式详细信息
     */
//    @RequiresPermissions("system:exhibitionType:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoGalleryExhibitionTypeService.selectDanmoGalleryExhibitionTypeById(id));
    }

    /**
     * 新增展览方式
     */
//    @RequiresPermissions("system:exhibitionType:add")
    @Log(title = "展览方式", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoGalleryExhibitionType danmoGalleryExhibitionType)
    {
        return toAjax(danmoGalleryExhibitionTypeService.insertDanmoGalleryExhibitionType(danmoGalleryExhibitionType));
    }

    /**
     * 修改展览方式
     */
//    @RequiresPermissions("system:exhibitionType:edit")
    @Log(title = "展览方式", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoGalleryExhibitionType danmoGalleryExhibitionType)
    {
        return toAjax(danmoGalleryExhibitionTypeService.updateDanmoGalleryExhibitionType(danmoGalleryExhibitionType));
    }

    /**
     * 删除展览方式
     */
//    @RequiresPermissions("system:exhibitionType:remove")
    @Log(title = "展览方式", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoGalleryExhibitionTypeService.deleteDanmoGalleryExhibitionTypeByIds(ids));
    }
}
